﻿using System;
/*
    Write a program that reads the coefficients a, b and c of a quadratic equation ax2 + bx + c = 0 
    and solves it (prints its real roots).
 */

class QuadraticEquation
{
    private static void checkingDiscriminant(double coefficientA, double coefficientB, double discriminant)
    {
        if (discriminant < 0)
        {
            Console.WriteLine("Discriminant is < 0!");
        }
        if (discriminant == 0)
        {
            Console.WriteLine("Discriminant is = 0");
            Console.WriteLine("Quadratic equation has one root: x1 = " +
                (-coefficientB) / (2 * coefficientA));
        }
        if (discriminant > 0)
        {
            Console.WriteLine("Discriminant is > 0");
            Console.WriteLine("Quadratic equation has two roots: x1 = {0} x2 = {1}", ((-coefficientB + (Math.Sqrt(discriminant))) / (2 * coefficientA)), ((-coefficientB - (Math.Sqrt(discriminant))) / (2 * coefficientA)));
        }
    }
    static void Main()
    {

        double coefficientA;
        double coefficientB;
        double coefficientC;
        double discriminant;

        Console.WriteLine("Enter a first number: ");
        coefficientA = double.Parse(Console.ReadLine());
        Console.WriteLine("Enter second number: ");
        coefficientB = double.Parse(Console.ReadLine());   
        Console.WriteLine("Enter Third number: ");
        coefficientC = double.Parse(Console.ReadLine());

        discriminant = (coefficientB * coefficientB) - 4 * coefficientA * coefficientC;

        checkingDiscriminant(coefficientA, coefficientB, discriminant);
        
    }


}
